package org.hive.vmware.translator;

import org.hive.vmware.model.VmCenterServer;

public class VmCenterServerModelDiskPersistenceTranslator {

		
	public VmCenterServer translateVmCenterServerToModel(String centerserver) {
		VmCenterServer result = null;
		if (centerserver != null && centerserver.trim().length() > 0) {
			String[] strings = centerserver.split(",");
			if (strings.length == 3) {
				result = new VmCenterServer();
				result.setId(strings[0]);
				result.setUserId(strings[1]);
				result.setPassword(strings[2]);
			}	
		}
			
		return result;
	}
	
	public String translateVmCenterServerToPersistence(VmCenterServer vmCenterServer) {
		StringBuilder builder = new StringBuilder();
		builder.append(vmCenterServer.getId());
		builder.append(",");
		builder.append(vmCenterServer.getUserId());
		builder.append(",");
		builder.append(vmCenterServer.getPassword());
		return builder.toString();
	}
	
	
}
